import request from '@/utils/request'
import { fetchEventSource } from '@microsoft/fetch-event-source';
import {getToken} from "@/utils/auth";
export function communication(data){
  return request({
    url: '/sparkApi/communication',
    method: 'post',
    data: data
  })
}


export function communicationStream(data){
  const ctrl = new AbortController();
  fetchEventSource(process.env.VUE_APP_BASE_API
      +'/sparkApi/communicationStream', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
        'Authorization': getToken()
    },
    body: JSON.stringify(data),
    signal: ctrl.signal
  });
  return ctrl;
}
